import { ConfigService } from '../../../../core/common/config.service';
import { BaseService } from '../../../../core/service/base.service';
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
@Injectable()
export class PortalService extends BaseService {
      constructor(protected http: Http, protected config: ConfigService) {
            super(http, config);
      }
      // 获取当前账号下的所有节点信息
      public getMarkers(): Observable<any> {
            const url = this.config.get('wuhan') + 'gethealthdetailinfo';
            const obj = {
                  'convertValue': '1'
            };
            return this.http.post(url, obj).map((res: Response) => {
                  const body = res.json();
                  return body;
            });
      }
      // 获取与本节点相关的所有链路信息
      public getNodesLink(devname): Observable<any> {
            const url = this.config.get('wuhan') + 'getDevInfo';
            const obj = {
                  'convertValue': '1',
                  'startdate': '24hoursAgo',
                  'enddate': 'today',
                  'device': devname,
            };
            return this.http.post(url, obj).map((res: Response) => {
                  const body = res.json();
                  return body;
            });
      }
      public statusDetail(val): Observable<any> {
            const url = this.config.get('wuhan') + val;
            const obj = {
                  convertValue: '1'
            };
            return this.http.post(url, obj).map((res: Response) => {
                  const body = res.json();
                  return body;
            });
      }
      public wholenetBwRank(): Observable<any> {
            const url = this.config.get('wuhan') + 'getweekappinfo';
            const obj = {
                  startdate: '7daysAgo',
                  enddate: 'today',
                  convertValue: '1'
            };
            return this.http.post(url, obj).map((res: Response) => {
                  const body = res.json();
                  return body;
            });
      }
      public nodeBwRank() {
            const url = this.config.get('wuhan') + 'getDevBandwidth';
            const obj = {
                  startdate: '7daysAgo',
                  enddate: 'today',
                  convertValue: '1'
            };
            return this.http.post(url, obj).map((res: Response) => {
                  const body = res.json();
                  return body;
            });
      }
}
